; $40-47 are already used by prodos so we can use them
serr equ $bf0f
zpsize equ 8
 ifeq opers-prodos
cmndlist equ $40
 else
cmndlist equ 0
 fin
execadr equ cmndlist+2
*
************** see rev note #en3 ***************
*
* the following address table contains entries into the atp, pap
* fap etc. drivers.  there is room for 16 entry addresses.
*
 ifne ednet
start.entries equ *
 dw atalkprg ; entry (0) to atp drivers.
 dw $e500 ; entry (1) to pap drivers.
 dw $e000 ; entry (2) to rpm driver.
 dw $0000 ; entry (3) to fap drivers.
 dw inthandler ; entry (4) to atp interrupt handler.
 dw $0000 ; entry (5) to rpm close routine.
 ds start.entries+32-* ; remaining space in entry table.
 fin
*
******************************************************
*
 ifeq opers-prodos+ednet
;
; entry point from mli
;
* note that the following code that increments the parameter list
* pointer should not be assembled for the ednet version of prodos.
* this is done by prodos itself, so it can then use x/y entry point.
*
frommli equ *
 inc cmndlist
 bne fmli.1
 inc cmndlist+1
fmli.1 jsr atlkprg2
 sta serr
fmli.9 rts
;
 fin
;
 ifeq opers-prodos
atalkprg equ *
 stx cmndlist
 sty cmndlist+1
 else ; pascal and kernel saves zero page
atalkprg equ *
 cld
; drcallct starts as $ff, first time it is called it becomes $00
; second times it becomes $01
 txa
 ldx intrflag ; are we in an interrupt
 bne atlkprg1 ; yes, no need to save zero page
 ldx indriver ; did we save it before
 bne atlkprg1 ; then no need to save zero page
 pha
 ldx #zpsize-1 ; save zero page
 lda cmndlist,x
 sta savezp1,x
 dex
 bpl *-6
 pla
atlkprg1 sta cmndlist
 sty cmndlist+1
 inc indriver ; mark it as in driver already
 fin
atlkprg2 ldy #0 ; point to command
 sty status ; clear error flag
 lda (cmndlist),y
 and #$7f ; ignore high bit
 cmp #maxcmnd
 bcs bdcmnd
 bit openflag ; are we open already
 bmi cmndok
 cmp #1 ; is it open command
 bne ntopen ; if not, driver not open error
cmndok asl a ; * 2 for displacement into table
 tax
 lda cmndtable,x
 sta execadr
 lda cmndtable+1,x
 sta execadr+1
 iny
 lda (cmndlist),y ; prefetch first operand
 jsr doexecute ; execute the routine
 ifne opers-prodos
cmnddone dec indriver ; now we are existing from driver
 bne atlkprg8 ; no need to restore if we are still in it
 lda intrflag ; do we need to restore zero page
 bne atlkprg8 ; not if we call from interrupt
 ldx #zpsize-1
 lda savezp1,x
 sta cmndlist,x
 dex
 bpl *-6
atlkprg8 equ *
 fin
 lda status ; was everything ok ?
 bne err.rts
 clc ; indicates ok
 rts
 ifeq opers-prodos
bdcmnd lda #badcmnd
err.rts sec ; indicates error
 rts
ntopen lda #nodriver
 sec
 rts
 else
err.rts sec
 rts
bdcmnd lda #badcmnd
 bne ntopen+2
ntopen lda #nodriver
 sta status
 bne cmnddone ; bra
 fin
;
openflag db 0
status db 0
 ifne opers-prodos
savezp1 ds zpsize,0
intrflag dfb 0
indriver dfb 0
 fin
;
toomanycollison equ $60+8
badcmnd equ $60+11
nodriver equ $60+12
alreadyopen equ $60+13
nointcard equ $60+14
illegalvalue equ $60+15
badsocket equ $60+16
socketopen equ $60+17
scktnotopen equ $60+18
toomanyreq equ $60+19
bufferfull equ $60+20
notconfirmed equ $60+21
diffsocket equ $60+22
requestfail equ $60+23
reqabort equ $60+24
;
maxcmnd equ 18+1
cmndtable dw bdcmnd
 dw opendriver
 dw closedriver
 do nolap
 dw bdcmnd
 else
 dw writelap
 fin
 dw sethook
 dw openddpsckt
 dw writeddp
 dw closeddpsckt
 dw lookupname
 dw confirmname
 dw bdcmnd
 dw bdcmnd
 dw sndatprq
 dw openatpsckt
 dw closeddpsckt
 dw agetrequest
 dw atpsndresponse
 dw killrspcb
 dw cancelatpreq
;
;
;
applebus lda cardslot
 jmp $c712
; the next 4 bytes (6 for prodos) are to be copied back to opendriver parm
; and therefore must be group together in the exact order
; note the cardslot is also part of the routine applebus
cardslot equ applebus+5
dataarea equ *-1 ; so that all displacement is non-zero
ournode dfb 0
 dw inthandler
 ifeq opers-prodos
 dw atalkprg
 fin
;
const0 dfb 0
const1 dfb 1
const2 dfb 2
const5 dfb 5
const8 dfb 8
const13 dfb 13
const16 dfb 16
chksmf db 0
curcksum dw 0
bridgetime dw 0
wddpparm db 3
wddptbl dw 0
wddpsize dw 0,lapdata
version dfb $ff
cardversion dfb 0
thisnet dw 0
 dfb 0 ; this should contains value of 8 to indicates 8 bits
a.bridge db 0
outnbp dfb $21 ; lkup with 1 tuple
outnbpid dfb 0
nbpbuffer ds 32,0
lapdata equ nbpbuffer+5
lapdest equ lapdata+0
lapsrce equ lapdata+1
laptype equ lapdata+2
ddphead equ lapdata+3
sd.length equ 0 ; use for parameter passing
sd.dsckt equ 2 ; use for parameter passing
sd.ssckt equ 3 ; use for parameter passing
sd.protocol equ 4
ld.length equ 0
ld.chksum equ 2
ld.dnet equ 4 ; use for parameter passing
ld.snet equ 6
ld.dnode equ 8
ld.snode equ 9
ld.dsckt equ 10
ld.ssckt equ 11
ld.protocol equ 12 ; use for parameter passing
atpheader equ ddphead+ld.protocol+1
